package com.stone.serverless.event.domain;

import com.stone.serverless.event.enums.EventTypeEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * @Description: TODO
 * @Author: MECHREVO
 * @Date: 2022/2/7 10:31
 * @Version: 1.0.0
 */
@Getter
@Setter
public class EventKey<T> {

    String key;

    T data;

    EventTypeEnum eventTypeEnum;

    public EventKey(String key) {
        this.key = key;
    }

    public EventKey(T data) {
        this.data = data;
    }

    public EventKey(String key, T data) {
        this.key = key;
        this.data = data;
    }

    public EventKey(String key, T data, EventTypeEnum eventTypeEnum) {
        this.key = key;
        this.data = data;
        this.eventTypeEnum = eventTypeEnum;
    }

    public static <T> EventKey<T> of(String key, T t){
        return new EventKey<T>(key,t);
    }
    public static <T> EventKey<T> of(String key,T t,EventTypeEnum eventTypeEnum){
        return new EventKey<T>(key,t,eventTypeEnum);
    }
    public static <T> EventKey<T> of(T t){
        return new EventKey<T>(t.getClass().getName(),t);
    }
}
